package com.xuelang;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import com.xuelang.pipeline.artifact.app.nexus3v1.response.SearchAssetResponse;
import com.xuelang.pipeline.artifact.client.common.constant.Constant;

import java.util.Optional;

/**
 * @author xiwen.zxg
 * @since 2024/6/20
 */
public class MainTest {

    public static void main(String[] args) {
        System.out.println(LocalDateTimeUtil.now());
        System.out.println(DateUtil.now());
        String string = "admin/127.0.0.1";
        System.out.println(string.split("/")[0]);

        System.out.println(Optional.of(string.split(Constant.DEFAULT_URL_PATH_SEPARATOR)).map(strings -> strings[0]).orElse(""));

        String s = "{\n" +
                "    \"items\": [\n" +
                "        {\n" +
                "            \"downloadUrl\": \"http://localhost:18081/repository/system-test3-maven/com/xuelangyun/devops/pipeline-client/3.0.0-SNAPSHOT/pipeline-client-3.0.0-SNAPSHOT.pom.sha512\",\n" +
                "            \"path\": \"com/xuelangyun/devops/pipeline-client/3.0.0-SNAPSHOT/pipeline-client-3.0.0-SNAPSHOT.pom.sha512\",\n" +
                "            \"id\": \"c3lzdGVtLXRlc3QzLW1hdmVuOjFhNjg3NGQzMWJhODQ2ODEwYjBjYTI3YjgzNmM3MzE4\",\n" +
                "            \"repository\": \"system-test3-maven\",\n" +
                "            \"format\": \"maven2\",\n" +
                "            \"checksum\": {\n" +
                "                \"test\": \"s\",\n" +
                "                \"test1\": \"2\",\n" +
                "                \"test2\": \"3\",\n" +
                "                \"test3\": \"3\"\n" +
                "            },\n" +
                "            \"contentType\": \"text/plain\",\n" +
                "            \"lastModified\": \"2024-07-16T02:00:28.031+00:00\",\n" +
                "            \"lastDownloaded\": null,\n" +
                "            \"uploader\": \"admin\",\n" +
                "            \"uploaderIp\": \"127.0.0.1\",\n" +
                "            \"fileSize\": 128,\n" +
                "            \"blobCreated\": null,\n" +
                "            \"maven2\": {\n" +
                "                \"extension\": \"pom.sha512\",\n" +
                "                \"groupId\": \"com.xuelangyun.devops\",\n" +
                "                \"artifactId\": \"pipeline-client\",\n" +
                "                \"version\": \"3.0.0-SNAPSHOT\"\n" +
                "            }\n" +
                "        }\n" +
                "    ],\n" +
                "    \"continuationToken\": null\n" +
                "}";


        SearchAssetResponse entries = JSON.parseObject(s, SearchAssetResponse.class);
        //JSONObject entries = JSON.parseObject(s, JSONObject.class);
        System.out.println(JSON.toJSONString(entries));
    }
}
